﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Produce.Application.DTO.Input;
using Produce.Application.DTO.Output;
using Produce.Application.Services;
using Produce.Result;
using System.Collections.Generic;


namespace Produce.Api.Controllers
{
    /// <summary>
    /// 生产日期排班控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductionDateController : ControllerBase
    {
        private readonly IProductionDateService _service;
        private readonly ILogger<ProductionDateController> _logger;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="service">服务</param>
        /// <param name="logger">日志</param>
        public ProductionDateController(IProductionDateService service, ILogger<ProductionDateController> logger)
        {
            _service = service;
            _logger = logger;
        }

        /// <summary>
        /// 获取指定人员的排班情况
        /// </summary>
        /// <param name="input">查询参数</param>
        /// <returns>排班情况</returns>
        [HttpGet]
        public IActionResult GetPersonSchedule([FromQuery] GetPersonScheduleInput input)
        {
            _logger.LogInformation($"查询ID为 {input.PersonId} 的人员排班情况，时间：{DateTime.Now}");
            return Ok(_service.GetPersonSchedule(input));
        }

        /// <summary>
        /// 设置指定人员的排班
        /// </summary>
        /// <param name="input">排班信息</param>
        /// <returns>操作结果</returns>
        [HttpPost]
        public IActionResult SetPersonSchedule([FromBody] PersonScheduleInput input)
        {
            _logger.LogInformation($"设置ID为 {input.PersonId} 的人员排班情况，时间：{DateTime.Now}");
            return Ok(_service.SetPersonSchedule(input));
        }
    }
}
